<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动</title>
    <style>
        /* 对于没有设置高度的父盒子，
        不添加浮动元素会导致后面的盒子挤上来
         */
        .clearflex:after{
            content: "";
            height: 0;
            display: block;
            clear: both;
            visibility: hidden;
        }
        .border{
            width: 30px;
            height: 30px;
            background-color: grey;
            float: left;
        }
    </style>
</head>
<body>
    <div class="clearflex">
        <div class="border"></div>
        <div class="border"></div>
    </div>
    <div style="height: 100px; width: 100px; background-color: black;"></div>
</body>
</html>